package leetcode100;

import java.util.Map;

public class lcc056 {


    public int maxProduct(int[] nums) {
        int maxRes = nums[0];
        int curMax = nums[0];
        int curMin = nums[0];

        for (int i = 1; i < nums.length; i++) {
            int lastMax = curMax;
            int num = nums[i];

            curMax = Math.max(num,Math.max(lastMax*num,curMin*num));
            curMin = Math.min(num,Math.min(lastMax*num,curMin*num));

            maxRes = Math.max(maxRes,curMax);
        }


        return maxRes;
    }


}
